home *** CD-ROM | disk | FTP | other *** search
/ Software Vault: The Gold Collection / Software Vault - The Gold Collection (American Databankers) (1993).ISO / cdr46 / strx221.zip / BCSTR.CPP next >
C/C++ Source or Header  |  1993-03-01  |  1KB  |  49 lines

  1. //
  2. // BCstr.cpp -- Borland object based str implementation
  3. // Author  : Roy S. Woll
  4. //
  5. // Copyright (c) 1993 by Roy S. Woll
  6. // You may distribute this source freely as long as you leave all files
  7. // in their original form, including the copyright notice as is.
  8. //
  9. // Version 1.00     10/20/92
  10. //
  11. #include "BCstr.h"
  12. #include <stdlib.h>
  13.  
  14. BCstr::BCstr (void):str(){};
  15. BCstr::BCstr (int p_bufsize, int p_incr):str(p_bufsize, p_incr){};
  16. BCstr::BCstr (const char * s, int p_bufsize, int p_incr):
  17.      str(s,p_bufsize, p_incr){};
  18. BCstr::BCstr (const str& s, int p_bufsize, int p_incr):
  19.           str(s,p_bufsize, p_incr){};
  20. BCstr::BCstr (const BCstr& s, int p_bufsize, int p_incr):
  21.           str(s, p_bufsize, p_incr){};
  22.  
  23. // Relational Operators
  24. int BCstr::isLessThan(const Object& b) const{
  25.   return compare(*this, (BCstr &) b)<0;
  26. };
  27.  
  28. int BCstr::isEqual(const Object& b) const{
  29.   return compare(*this, (BCstr &) b)==0;
  30. };
  31.  
  32.  
  33. hashValueType BCstr::hashValue() const  // use Borland's String hash function
  34. {
  35.     hashValueType   value = hashValueType(0);
  36.     for( int i = 0; i < length(); i++ )
  37.         {
  38.         value ^= data->buf[i];
  39.         value = _rotl( value, 1 );
  40.         }
  41.     return value;
  42. }
  43.  
  44. void BCstr::printOn( ostream& outputStream ) const
  45. {
  46.     outputStream << (str&)*this;
  47. }
  48.  
  49.